let logger = require('log4js').getLogger('mongoose');
let dbPath = require('../config/config.json').DbPath;
// var dbPath =  process.env.MONGOLAB_URI;
let mongoose = require('mongoose'),
  extend = require('mongoose-schema-extend');
mongoose.Promise = global.Promise;
// use custom mongodb url or localhost
let db =mongoose.createConnection(dbPath || "mongodb://localhost:27017/mySite");
//let db = mongoose.connection;
db.on('error', function (err) {
  logger.error('连接mongodb数据出错!');
  process.exit(1);
});

module.exports = {
  'base' : mongoose,
  'mongoose': db,
  'Schema': mongoose.Schema
};
/*
//基础Schema
let base = new mongoose.Schema({
  // 创建时间
  createTime: {type: Date, default: Date.now},
  // 修改时间
  updateTime: {type: Date, default: Date.now},
  // 删除时间
  deleteTime: {type: Date},
  // 操作人
  operator: {type: String},
  // 操作人id
  operatorId: {type: String},
  // 备注
  remarks: {type: String}
});

exports.base = base;
*/
